function getLanguage() {
  //返回缓存中的language属性 (en / zh_CN) 	
  return wx.getStorageSync('Language') || 'zh_CN'
};

function translate(){
  //返回翻译的对照信息 
  return require('../i18n/'+ getLanguage() + '.js').languageMap;
}

function translateTxt(desc){
  //翻译	
  return translate()[desc] || '竟然没有翻译';
}

function switchLanguage() {
	console.log('switchLanguage')
  if (getLanguage() == 'zh_CN'){
	this.setData({ language:'wei' })
	wx.setStorageSync('Language', 'wei')
  }else{
	this.setData({ language:'中文' })
	wx.setStorageSync('Language', 'zh_CN')
  }
  let isWei = isWeiFn()
  this.setData({ _t: translate(), isWei: isWei })
  this.onLoad()
  this.onShow()
}

function isWeiFn(){
	return wx.getStorageSync('Language') === 'wei'
}

module.exports = {
  switchLanguage: switchLanguage,
  getLanguage: getLanguage,
  _t: translate,
  _: translateTxt,
  isWeiFn,
}